//https://leetcode.cn/problems/maximum-beauty-of-an-array-after-applying-operation/?envType=daily-question&envId=2024-06-15
class Solution {
public:
    int maximumBeauty(vector<int>& nums, int k) {
       int tmp = 100002;
       vector<int> dp(2000010);
        for(auto e : nums){
            dp[e-k+tmp]+=1;
            dp[e+k+tmp+1]-=1;
        }
        int ret = 0,t = 0;
        for(int i = 0 ;i < 200010;i++){
            t += dp[i];
            ret = max(ret,t);
        }
        return ret;
    }
};